﻿using H.Hands;
using H.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace H.KML.KeyBoards
{
    /// <summary>
    /// 点击单个按钮的按键任务
    /// </summary>
    public class KMKeys : IKeyBoard
    {
        /// <summary>
        /// Hand实例
        /// </summary>
        protected readonly KMHand _Hand;

        /// <summary>
        /// 需要按下的键
        /// </summary>
        private readonly string[] _Key = new string[6];

        /// <summary>
        /// 构造一个按键任务
        /// </summary>
        /// <param name="key"></param>
        public KMKeys(KMHand hand, string[] key)
        {
            _Hand = hand;
            Array.Copy(key, 0, _Key, 0, key.Length);
        }


        ///<inheritdoc/>
        public bool Click()
        {
            return _Hand._KM.CombinationKeyPress(_Key[0], _Key[1], _Key[2], _Key[3], _Key[4], _Key[5], 1) == 1;
        }

        ///<inheritdoc/>
        public bool Down()
        {
            return _Hand._KM.CombinationKeyDown(_Key[0], _Key[1], _Key[2], _Key[3], _Key[4], _Key[5]) == 1;
        }

        ///<inheritdoc/>
        public bool Up()
        {
            return _Hand._KM.CombinationKeyUp(_Key[0], _Key[1], _Key[2], _Key[3], _Key[4], _Key[5]) == 1;
        }
    }
}
